from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://www.baidu.com/')
driver.maximize_window()

# 基础选择器
# id选择器定位
print(driver.find_element(By.CSS_SELECTOR, '#kw').get_attribute('outerHTML'))

# class选择器定位
print(driver.find_element(By.CSS_SELECTOR, '.s_ipt').get_attribute('outerHTML'))

# 标签+属性选择器定位
print(driver.find_element(By.CSS_SELECTOR, 'input[name="wd"]').get_attribute('outerHTML'))

driver.quit()
